home *** CD-ROM | disk | FTP | other *** search
/ Super PC 28 / Super PC 28 (Shareware para Windows 95 y MS-DOS).iso / spc / util / inter45 / int2whlp / int2whlp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-07  |  43.8 KB  |  1,266 lines

  1. (*
  2.   Interrupt List -> WinHelp converter (c) 1994 by Christian Müller-Planitz
  3.   ------------------------------------------------------------------------
  4.   e-mail address: see CONST "e_mail"
  5.  
  6.  
  7.   The source and the compiled EXE-file can be freely distributed as long as
  8.   no changes are made without my knowledge.
  9.  
  10.   --------------------------------
  11.   Notes:
  12.    The program was tested with INTLIST38 and INTLIST39 and its output
  13.      was successfully compiled with the MS-Help-compiler "HC31.EXE" V3.10.445.
  14.  
  15.    The program needs the file "INTWHLP.DAT" in the 'source' directory.
  16.  
  17.    The program converted all sourcefiles (INTERRUP.* and *.LST) to
  18.      13 RTF files which needed 11MB on my harddrive.
  19.  
  20.    Compiling the RTF-files without compression took 13 minutes in
  21.      a DOS-Window under Win/NT on a 486-50 (if you run it under DOS
  22.      and if you have a fast hardrive cache, it might be faster).
  23.  
  24.    The (uncompressed) compiled HLP-File was approximately 7MB large.
  25.    If you want to create a compressed HLP-file, you have to exchange the
  26.      comments in the generated help-project file ("RB.HPJ"). Compressing
  27.      reduces the size of the HLP-file to 3MB but it takes
  28.      *more* (?? 28MB ??)  space on your harddrive while compiling.
  29.      In order to speed up compiling the compressed file, I've included a
  30.      temporary file ("INTWIN.PH") of the helpcompiler in this archive.
  31.      Copy this file into the directory containing all the RTF files
  32.      before starting the compiler. This file is specific for INTERLIST39, so
  33.      if you want to get maximal compression in future versions, remove it.
  34.  
  35.    After the compilation finishes, you will find the file "INTWIN.HLP".
  36.      Start Windows, create an icon in the program manager and double-click on it.
  37.  
  38.    Version 1.11:
  39.    The compressed INTWIN.HLP file compiled from Ralf Brown's Interrupt List
  40.      release 42 occupies appr. 4.6 MB.
  41.  
  42.   --------------------------------
  43.  
  44.    If you find this program usefull, if it does not work or if you have ideas
  45.    how to expand its functionality, feel fee to write an e-mail to me.
  46.  
  47.    As usual, I do not take any responsibility for possible damages done by
  48.    this program.
  49.  
  50.  
  51.   Two questions and their answers :
  52.   ---------------------------------
  53.    WHY is the HLP-file so large ?
  54.      In contrast to other programs that convert the interrupt list to
  55.      DOS-based hypertext systems, this program generates a large
  56.      index file that allows you to search for keywords.
  57.  
  58.    WHY did I wrote this program in Pascal and not in C ?
  59.      I think Pascal is a pretty nice language for small projects.
  60.      Another reason is the availability of efficient string handling under Pascal.
  61. *)
  62.  
  63. {$A+,B-,D+,E-,F-,I+,L+,N-,O-,R-,S-,V-}
  64. {$M 16384,25000,200000}
  65. (* minimum heap estimate (1994): 60*(6+10)+(30+40)*(43+10)+50*256=16770 *)
  66. (* (average entry size times (number of entries + 10) for FLAGS, CATEGORIES,
  67.    and CATEGORYKEYS entries) or times 256 for titles.
  68.    Each string in the [*ALIASES] sections requires (length of string) + 5.
  69. *)
  70.  
  71. Program INT2WHLP;
  72.  
  73. uses DOS;
  74.  
  75. { Version 1.00 - 1994
  76.   v. 1.01 -
  77.   v. 1.01a - 1994-02-16:
  78.     published with Ralf Brown's Interrupt List release 40.
  79.   v. 1.02 - 1994-04-07:
  80.     Changed program name from RB2HLP/INTWHLP to INT2WHLP.
  81.     Reduced the amount of RTF control codes.
  82.     Introduced program parameter controlled behaviour.
  83.     Improved flexibility by use of constants for parts of the control.
  84.     Changed and added some windows.
  85.     Extended search key facilities.
  86.   v. 1.03 - 1994-04-17:
  87.     Expanded/Compressed index switch.
  88.     Multi columns compressed index.
  89.     Interrupt titles OVERVIEW.LST.
  90.   v. 1.04 - 1994-04-29:
  91.     Configuration file including:
  92.       Program parameters can be defined in the configuration file. Such
  93.         definitions are overriden by program parameters.
  94.       Several WINHELP parameters, like font and size, can be specified.
  95.       Supplementary information "windows" can be included.
  96.       An ALIAS list can be compiled and written to the HPJ file.
  97.       A BUILDTAG list can be copied from the configuration to the HPJ file.
  98.   v. 1.05 - 1994-05-07:
  99.     Reconsidered default directories.
  100.   v. 1.06 - 1994-05-26:
  101.     Cross-references to tables.
  102.   v. 1.07 - 1994-05-29:
  103.     Edited procedure explain.
  104.     Skip "Section" file break sections (from a "--------!-Section--.."
  105.       divider line up to the next divider line).
  106.     Executable code released with Interrupt List release 41.
  107.     (ProgVers erroneously = '1.06').
  108.   v. 1.08 - 1994-07-10:
  109.     Tables as separate topics.
  110.   v. 1.10 - 1994-07-20:
  111.     Interrupt List release number dependent compilation.
  112.     Published with Interrupt List release 42.
  113.   v. 1.11 - 1994-09-20:
  114.     [INTWINCONFIG] section in configuration file.
  115.   v. 1.12 - 1994-11-04:
  116.     Test for long graphics lines in ReadLine().
  117.     Published with Interrupt List release 43.
  118.   v. 1.13 - 1994-12-26:
  119.     Transformation of DOS graphics in ReadLine().
  120.     Check for duplicate keywords (from CATEGORYKEYS) in NewHlpPage().
  121.     Secondary register references as keywords.
  122.     Separate RTF files for interrupts and tables, check for direct/inderect
  123.       references to tables from current interrupt.
  124.   v. 1.14 - 1995-03-07:
  125.     Return errorlevel 1 for warnings and >= 2 for errors.
  126. }
  127.  
  128. const
  129.   progName  = 'INT2WHLP';
  130.   progVers  = '1.14';
  131.   hfName    = 'INTWIN'; { helpfile name }
  132.   copyright = 'Copyright (C) 1994 by Christian Müller-Planitz';
  133.   e_mail    = '"cmuelle@eos.ncsu.edu" or "cmueller@techfak.uni-bielefeld.de"';
  134.     { e-mail address in Intro/Explain windows }
  135.   e_mailCredits = e_mail;
  136.     { e-mail address in the Credits window }
  137.  
  138.   { the strings ack01 ... are displayed in the Credits window }
  139.  
  140.   { thanks to (excuse the format): }
  141.   ack01 = '\par{\b Bent Lynggaard} for ideas, parts of the code, and the "Miscellaneous Information" entry.';
  142.   ack02 = '';
  143.   ack03 = '';
  144.   ack04 = '';
  145.   ack05 = '';
  146.   {if extended, update procedure "Credits"}
  147.  
  148.   {"errorlevel" constants:}
  149.   aliasErr    = 241; (* alias not found, or table exceeded *)
  150.   fileErr    = 242; (* cannot open file *)
  151.   formatErr    = 243; (* table exceeded, or fatal error in input file *)
  152.   paramErr    = 244; (* error in program parameter *)
  153.   rtfErr    = 245; (* unable to open output file *)
  154.   userErr    = 240; (* terminated by user *)
  155.  
  156. {$I INT2WHLP.INC }
  157.  
  158.   Procedure NewHlpPage(VAR F : Text; S, ID, BrowseID : String; Classification : Char);
  159.     type
  160.       intRec = record (* used for fast test and transfer of string *)
  161.     ln: byte;    (* string length *)
  162.     l: longint;  (* 'INT ' *)
  163.     n: word;     (* 'nn' *)
  164.     c7: char;    (* ' ' *)
  165.     l2: longint; (* 'ahal' or 'List' *)
  166.     c12: char;   (* ' ' *)
  167.     w: word;     (* '- ' *)
  168.       end; (* record intRec *)
  169.       nnRec = record ln: byte; w: word; (* for 'nn' *) end;
  170.       ahalRec = record ln: byte; l: longint; (* for 'ahal' *) end;
  171.     const
  172.       linebreak = #13#10'\par\tab';
  173.       intC = ord('I')+ord('N')*$100+ord('T')*$10000+ord(' ')*$1000000;
  174.       listC = ord('L')+ord('i')*$100+ord('s')*$10000+ord('t')*$1000000;
  175.       sepC = ord('-')+ord(' ')*$100;
  176.       int:  string[3] = 'nn';   (* preset length to 2, never changed *)
  177.     VAR
  178.       intR: nnRec absolute int; (* type cast *)
  179.       p,q : Word;
  180.       func: string[5];
  181.       funcR: ahalRec absolute func; (* type cast *)
  182.       ss: string;
  183.       ssR: intRec absolute ss;
  184.  
  185.     Procedure FootNote(Note: Char; ID : String);
  186.       begin
  187.     writeln(F, Note,'{\footnote{',Note,'} ', ID, '}');
  188.       end;
  189.  
  190.  
  191.     procedure insertInt;
  192.       begin
  193.     insert('INT '+int+equStr+func+';'+int+' '+func+';',ss,11);
  194.       (* "INT nn Ar = XXxx;nn XXxx;"  (XXxx = ahal, ah, or --al) *)
  195.     if equStr[3]='L' then delete(ss,21+equBlanks,2);
  196.       (* "--" from AL = --al *)
  197.     insert(copy(ss,18,6+equBlanks+2*ord(equStr[3]='X')),ss,11);
  198.       (* "Ar = XXxx;" *)
  199.       end; (* procedure insertInt in NewHlpPage *)
  200.     procedure insertSecReg(p, l: word);
  201.     (* duplicates part of SS and inserts secondary register *)
  202.       begin
  203.     insert(copy(ss,p,l),ss,p); (* duplicate *)
  204.     insert(secReg,ss,p+l+l-1); (* SXnnnn *)
  205.     insert(secReg,ss,p+l+p-5);
  206.     insert(equStr2,ss,p+l+p-2); (* SX = nnnn *)
  207.     insert(copy(secReg,2,7)+';',ss,p);   (* SXnnnn; *)
  208.     insert(equStr2,ss,p+2);    (* SX = nnnn; *)
  209.       end; (* procedure insertSecReg in NewHlpPage *)
  210.  
  211.     begin
  212.       writeln(F, '\page\pard\keepn\li'+indent+'\fi-'+indent);
  213.     (* the '\page' inserted unconditionally here will cause that each .RTF
  214.        file begin with an empty, unreferenced "topic". This is harmless.
  215.        It requires, though, that [OPTIONS] CONTENTS= is defined, or we
  216.        would be left in an empty topic without an exit.
  217.     *)
  218.       FootNote('#', ID);
  219.       if S<>'' then FootNote('$', S);
  220.       if BrowseID<>'' then FootNote('+', BrowseID);
  221.       if (Classification <> nullClassification) then begin
  222.     ss:=s;
  223.     if (ssR.l=intC) AND (ssR.c7=' ') then begin
  224.       if (length(ss)>14) AND (ssR.c12=' ') AND (ssR.w=sepC) then begin
  225.         (* insert highlight in s *)
  226.         insert('}}',s,7);
  227.         insert('{'+highlightInt+'{',s,1);
  228.           (* 2nd '{' terminates attribute, a ' ' distorts if attrib. is empty *)
  229.         (* insert tiny, short, and full form of INT *)
  230.         intR.w:=ssR.n;   (* length of "int" is preset to 2 *)
  231.         (* same as "int:=copy(ss,5,2);": nn from INT nn ahal - xxxx ... *)
  232.         funcR.l:=ssR.l2;
  233.         funcR.ln:=4;     (* func = 'ahal' *)
  234.         ss[7]:=';';      (* INT nn;ahal - xxxx ... *)
  235.         ss[8]:=int[1];
  236.         ss[9]:=int[2];
  237.         ss[10]:=';';     (* INT nn;nn;l - xxxx ... *)
  238.         delete(ss,11,4); (* INT nn;nn;xxxx ... *)
  239.         if func<>'----' then begin
  240.           if func[3]='-' then begin equStr[3]:='H'; func[0]:=#2; end
  241.           else if func[1]='-' then equStr[3]:='L'
  242.           else equStr[3]:='X';
  243.           insertInt;
  244.     (* INT nn;nn;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... or
  245.        INT nn;nn;AH = ah;INT nn AH = ah;nn ah;xxxx ... or
  246.        INT nn;nn;AL = al;INT nn AL = al;nn --al;xxxx ...
  247.     *)
  248.           if equStr[3]='H'then begin
  249.         insert(copy(ss,29+equBlanks+equBlanks,6)+'--',
  250.           ss,35+equBlanks+equBlanks);
  251.         insert('AX'+equStr2+copy(ss,39+equBlanks+equBlanks,5),
  252.           ss,17+equBlanks);
  253. (* INT nn;nn;AH = ah;AX = ah--;INT nn AH = ah;nn ah;nn ah--;xxxx ... *)
  254.           end; (* equStr[3]='H' *)
  255.           (* duplicate INT nn Ar = ... and insert secondary register
  256.          if appropriate.
  257.           *)
  258.           if secReg<>'' then case equStr[3] of
  259.         'X': insertSecReg(19+equBlanks, 23+equBlanks);
  260.         'H': insertSecReg(17+equBlanks, 19+equBlanks);
  261.         else insertSecReg(17+equBlanks, 21+equBlanks);
  262.           end; (* if secReg<>'' then case equStr[3] of *)
  263.           if equStr[3]='X' then begin (* insert also the AH values *)
  264.         equStr[3]:='H';
  265.         func[0]:=#2;
  266.         insertInt;
  267. (* INT nn;nn;AH = ah;INT nn AH = ah;nn ah;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... *)
  268.           end; (* if equStr[3]='X' *)
  269.         end (* if func<>'----' *)
  270.         else if secReg<>'' then insertSecReg(1, 10);
  271.       end (* if length(ss)>14 ... *)
  272.       else if (length(s)=11) and (ssR.l2=listC) then begin
  273.         insert(copy(ss,1,6)+';',ss,1); (* INT nn;INT nn List *)
  274.         insert(copy(ss,5,3),ss,8); (* INT nn;nn;INT nn List *)
  275.       end; (* else if ... *)
  276.     end; (* if (ssR.l=intC) ... *)
  277.     if Classification=tableClassification then begin
  278.       delete(ss,1,8); (* 'II SUBF ' *)
  279.       insert('#'+currentTable+';',ss,1);
  280.     end (* if Classification=tableClassification *)
  281.     else repeat
  282.       p := POS(' - ', ss);
  283.       if p <> 0 then
  284.         begin
  285.           ss[p] := ';';
  286.           delete(ss,succ(p),2);
  287.         end;
  288.     until p=0;
  289.     if (Classification <> InvalidClassification)
  290.         AND (Classification > ' ') then begin
  291.       if categoryKeyStrings[Classification]^<>'' then begin
  292.         (* check for duplicate before inserting *)
  293.         p:=pos(categoryKeyStrings[Classification]^,ss);
  294.         q:=length(categoryKeyStrings[Classification]^);
  295.         if (p=0) OR ((p+q<>length(ss)) AND (ss[p+q]<>';')) then
  296.           insert(categoryKeyStrings[Classification]^+';',ss,1);
  297.       end; (* if categoryKeyStrings[Classification]^<>'' *)
  298.       if (Classification<'A') OR (Classification>'Z') then
  299.         insert(Classification+';',ss,1)
  300.       else insert(Classification+'!;',ss,1);
  301.     end; (* if (Classification<>InvalidClassification) ... *)
  302.     FootNote('K', SS);
  303.       end; (* if (Classification<>nullClassification) *)
  304.  
  305.       write(F, '{\f0'+headerAttrib,headerSize,' ');
  306.       if classification=specialClassification then write(F, indexHeader);
  307.       writeln(F, S,'}');
  308.       writeln(F, '\par\pard\keep');
  309.  
  310.     end;
  311.  
  312.  
  313.   Procedure AddTopic(VAR F: Text; ST, S, ID: String);
  314.   { print: ST as a string (normally "\par " for new line), S as a hotspot,
  315.     ID as the corresponding jump address or macro.
  316.   }
  317.     const sp: array[0..7] of string[7] =
  318.       ('       ','      ','     ','    ','   ','  ',' ','');
  319.     var p: integer;
  320.     begin
  321.       repeat
  322.     (* detab S, otherwise the string cannot be selected with the cursor
  323.        in a tab position.
  324.     *)
  325.     p:=pos(#9,S);
  326.     if p<>0 then begin S[p]:=' '; insert(sp[(p-1) AND 7],S,p); end;
  327.       until p=0;
  328.       writeln(F, ST,'{\uldb ', S, '}{\v ', ID, '}');
  329.     end;
  330.  
  331.  
  332.   Procedure CheckKeyWords(VAR s : STring);
  333.     CONST KeyWords = 11;
  334.     CONST Keys : Array[1..KeyWords] of String[10] = ('Desc:', 'Notes:',
  335.       'Note:', 'Warning:', 'Index:', 'SeeAlso:', 'Return:', 'BUG:', 'BUGS:',
  336.       'Program:', 'Range:');
  337.     CONST IStr = '{\b ';
  338.     VAR q,p : Integer;
  339.  
  340.     begin
  341.  
  342.       if length(s)<251 then for q:= 1 to KeyWords do
  343.     begin
  344.       p := POS(Keys[q], S);
  345.       if p <> 0 then
  346.         begin
  347.           insert(IStr, S, p);
  348.           insert('}', S, p+Length(Keys[q]) + Length(IStr));
  349.           exit;
  350.         end;
  351.     end;
  352.     end;
  353.  
  354.  
  355.   Function GetSpecialNote(Note : Char)  : String;
  356.     begin
  357.       if flagStrings[Note]^='' then GetSpecialNote:='<unknown note in header>'
  358.       else GetSpecialNote:=flagStrings[Note]^;
  359.     end;
  360.  
  361.  
  362. procedure insertQueued;
  363.   var i,j: word;
  364.   begin
  365.     if (indexColumns>1) OR (queuedEntry='') then exit;
  366.     val('$'+lastSection,i,j);
  367.     if singlesInMain AND (INTcounts[i]=1) then
  368.       AddTopic(IntFile, nl, queuedEntry, lastSection+'_1')
  369.     else AddTopic(IntFile, nl, title, lastSection+'_0');
  370.     queuedEntry:='';
  371.   end; (* procedure insertQueued *)
  372.  
  373. function inArray(n: integer; var arr: tableArray; var top: integer): boolean;
  374. (* returns true if n is in arr, else false *)
  375.   var i: integer;
  376.   begin
  377.     i:=1;
  378.     while (i<=top) AND (arr[i]<>n) do inc(i);
  379.     inArray:=i<=top;
  380.   end; (* function inStack in function ProcessIntList *)
  381.  
  382. procedure toArray(n: integer; var arr: tableArray; var top: integer);
  383. (* inserts n in arr if not already present *)
  384.   begin
  385.     if inArray(n, arr, top) then exit;
  386.     if top=tableArraySize then errorExit('Table array exceeded',formatErr);
  387.     inc(top);
  388.     arr[top]:=n;
  389.   end; (* procedure toStack in function ProcessIntList *)
  390.  
  391.   Function ProcessIntList(FName : PathStr) : Boolean;
  392.     LABEL STOP, error_Exit, endOfLoop, table, fobi, noTable;
  393.     type
  394.       kind = (firstPart,inOverview,inFlags,inCategories,inKeys,
  395.     inFileBreakSection,pastTest);
  396.       tableId = array[1..4] of char;
  397.       sRec = record
  398.     l: byte; (* length *)
  399.     w: word; (* with '(T' *)
  400.     d: longint; (* with 'able' *)
  401.     c1: char; (* ' ' *)
  402.     ti: tableId;
  403.     c2: char; (* ')' *)
  404.       end; (* record sRec *)
  405.       castRec = record
  406.     l: byte;
  407.     case byte of
  408.       1: (w: word);
  409.       2: (d: longint);
  410.       3: (c: char (* space *); r: word; rv: longint);
  411.       end; (* record castRec *)
  412.       dividerRec = record
  413.     s: string[8];    (* '--------' *)
  414.     cat: char;    (* category *)
  415.     c: char;    (* '-' *)
  416.     w: word;    (* Interrupt number, 2 hex digits *)
  417.     d: longint;    (* sub function, 4 hex digits or '-' *)
  418.     r: word;    (* secondary register name, two letters or '--' *)
  419.     rv: longint;    (* sec. reg. value, 4 hex digits or '-' *)
  420.       end; (* record dividerRec *)
  421.     const
  422.       INTno:     integer = 0;
  423.       bufferString: string = ''; (* transfers part of split string *)
  424.       ta = ord('(')+ord('T')*$100; (* (Table nnnn) *)
  425.       able = ord('a')+ord('b')*$100+ord('l')*$10000+ord('e')*$1000000;
  426.       fo = ord('F')+ord('o')*$100; (* Format of ... *)
  427.       bi = ord('B')+ord('i')*$100; (* Bitfields for ... *)
  428.       Section: String[3] = '--'; (* initialize to length 2 *)
  429.       SubFunc: String[5] = '----'; (* length 4 *)
  430.       allMessages: boolean = false;
  431.  
  432.     VAR
  433.     tP:          ^tableID;
  434.     hLineP,tLineP : ^string; (* pointers to header and (Table) lines *)
  435.     p,q        : integer;
  436.     curTab     : integer;
  437.     lineCount  : word; (* for error report *)
  438.     NewSection : Boolean;
  439.     Classification,c      : Char;
  440.     current    : kind;
  441.     inTable    : boolean;
  442.     table_Id   : String[7];
  443.     tableTitle : String[119];
  444.     s          : String;
  445.     SpecialNote : String;
  446.     sR         : sRec absolute s; (* for type cast *)
  447.     sectionR   : castRec absolute Section;
  448.     subFuncR   : castRec absolute SubFunc;
  449.     secRegR    : castRec absolute secReg;
  450.     dR         : dividerRec absolute s;
  451.  
  452.     F1         : Text;
  453.  
  454.     function isNumber(var ti: tableId): integer;
  455.     (* returns the table number, or negative value if illegal number *)
  456.       var i,res: integer;
  457.       begin
  458.     res:=0;
  459.     for i:=1 to 4 do case ti[i] of
  460.       '0'..'9': res:=res*10+ord(ti[i])-ord('0');
  461.       else begin isNumber:=-1; exit; end;
  462.     end; (* for ... do case ... *)
  463.     isNumber:=res;
  464.       end; (* function isNumber in function ProcessIntList *)
  465.     procedure insertRef;
  466.       begin
  467.     if inTable then AddTopic(TabTopics,nl,'INT '+Section+' '+SubFunc, TopicStr+mainW)
  468.     else if IntTopicStr<>'' then AddTopic(IntTopics,nl,copy(title,1,6),IntTopicStr);
  469.       end; (* procedure insertRef in function ProcessIntList *)
  470.     procedure wrSection; (* show progress *)
  471.       begin write(Section,#13); end;
  472.  
  473.     begin
  474.      {$I-}
  475.       assign(F1, InPath + FName);
  476.       reset(F1);
  477.      {$I+}
  478.       if IOResult <> 0 then
  479.     begin
  480.       ProcessIntList := FALSE;
  481.       EXIT;
  482.     end;
  483.  
  484.       writeln('Processing : ', InPath + FName);
  485.       write(LastSection,#13);
  486.  
  487.       readLine(F1, s);    { ignore copyright in 1st two lines }
  488.       readLine(F1, s);
  489.       lineCount:=2;
  490.       current:=firstPart;
  491.       inTable:=false;
  492.  
  493.       SpecialNote := '';
  494.  
  495.  
  496.       while not(EOF(F1)) do
  497.     begin
  498.       readLine(F1, s);
  499.       inc(lineCount);
  500.       NewSection := (s[1]= '-') and (Pos('--------', s) <> 0);
  501.  
  502.       if NewSection then
  503.         begin
  504.           if inTable then insertRef;
  505.           for p:=1 to tabTop do begin
  506.         q:=tabArray[p];
  507.         if NOT inArray(q, refArray, refTop) then begin
  508.           str(10000+q,table_Id); (* 1nnnn *)
  509.           delete(table_Id,1,1);  (* nnnn  *)
  510.           AddTopic(intTopics,nl,'Table #'+table_Id,'t'+table_Id+tableW);
  511.           inc(insertCounter);
  512.         end; (* if NOT inArray() *)
  513.           end; (* for p:=1 *)
  514.           inTable:=false;
  515.           insertRef;
  516.           if tabTop>maxTabTop then maxTabTop:=tabTop;
  517.           tabTop:=0;
  518.           if refTop>maxRefTop then maxRefTop:=refTop;
  519.           refTop:=0;
  520.  
  521.           SectionR.w:=dR.w; (* chars 11..12 of divider line *)
  522.           SubFuncR.d:=dR.d; (* chars 13..16 of divider line *)
  523.           secRegR.r:=dR.r;  (* chars 17..18 of divider line *)
  524.           if secReg[2]='-' then secReg[0]:=#0
  525.           else begin
  526.         secRegR.rv:=dR.rv; (* chars 19..22 of divider line *)
  527.         if secReg[6]='-' then secReg[0]:=#5 else secReg[0]:=#7;
  528.           end; (* else *)
  529.           Classification := s[9];
  530.           if Classification = '!' then
  531.         begin
  532.           delete(s,1,12);
  533.  
  534.           q:=0;
  535.           while (s[q] <> '-') and (q < Length(s)) do
  536.             Inc(q);
  537.           s[0] := chr(q-1);  { remove '-' chars at the end }
  538.           if s='OVERVIEW' then current:=inOverview
  539.           else if s='FLAGS' then current:=inFlags
  540.           else if s='CATEGORIES' then current:=inCategories
  541.           else if s='CATEGORYKEYS' then current:=inKeys
  542.           else if s='Section' then begin
  543.             current:=inFileBreakSection;
  544.             Section:=LastSection;
  545.             IntTopicStr:='';
  546.             goto endOfLoop; (* skip file break section *)
  547.           end (* if s='Section' *)
  548.           else current:=firstPart;
  549.           (* Interrupt List release 41 does not include OVERVIEW
  550.              and CATEGORYKEYS as sections, but as separate files.
  551.              The program is prepared for this information being
  552.              parts of the List.
  553.           *)
  554.  
  555.           if s = '' then s:= 'Note';   { shit ! }
  556.  
  557.           if EOF(F1)  then   { last line of document ?}
  558.             goto STOP;
  559.           inc(TopicNo);
  560.           str(TopicNo, TopicStr);
  561.         end { if Classification = '!' }
  562.           else
  563.         begin
  564.           if section<>lastSection then begin
  565.             val('$'+section,INTno,q);
  566.             if q<>0 then begin
  567.               writeln('Cannot interpret interrupt number in line ',
  568.             lineCount,': "',section,'".');
  569.               goto error_Exit;
  570.             end; (* if q<>0 *)
  571.           end; (* if section<>lastSection *)
  572.           current:=pastTest;
  573.           readLine(F1, s);
  574.           inc(lineCount);
  575.           inc(INTcounts[INTno]);
  576.           str(INTcounts[INTno], TopicStr);
  577.           insert(section+'_',TopicStr,1);
  578. (* We could compare already here: "while aliasString=s do ..." if we want to
  579.    use the orginal interrupt header line to find aliases. However,
  580.      1. it is easier to identify the original position of an alias line,
  581.      2. it is easier to determine the alias sequense in the config. file,
  582.      3. it is easier to track the reason for a "not found" error, and
  583.      4. the chance for an alias line to be unique is higher
  584.    if we compare after the manipulation of the header line. Also, if we copy
  585.    from the INTWIN index rather than from the original list, the lines are
  586.    already manipulated.
  587. *)
  588.           while (s[8] <> '-') do   { special flags in titel-line ? }
  589.             begin
  590.               if s[8] <> ' ' then
  591.             SpecialNote:=SpecialNote+#13#10'\par '+GetSpecialNote(s[8]);
  592.               delete(s, 8, 1);
  593.             end;
  594.  
  595.           Insert(subFunc+' ', S, 8);
  596.           while aliasString=S do begin
  597.             saveAlias(nextAliasPP,aliasId+TopicStr);
  598.             getNextAlias(aliasP,aliasId,aliasString);
  599.           end; (* while aliasString=S *)
  600.         end; { else (Classification<>'!') }
  601.  
  602.           if LastSection <> Section then
  603.         begin
  604.           if Classification = '!' then begin
  605.             if indexColumns=1 then insertQueued;
  606.             IntTopicStr:='N_'+TopicStr;
  607.             title:='Notes';
  608.             if (notesCount MOD indexColumns)=0 then write(IntFile,'\par ')
  609.             else  write(IntFile,'\tab ');
  610.             inc(notesCount);
  611.             writeln(IntFile,'{\uldb Notes}{\v ',IntTopicStr,'}');
  612.           end (* if Classification = '!' *)
  613.           else begin (* (Classification <> '!'*)
  614.             if INTno<lastINTno then begin
  615.               (* we cannot tolerate inconsistent sorting in a
  616.              multi-column index.
  617.               *)
  618.               writeln('Inconsistent sorting in file ',FName,
  619.             ' line ',lineCount);
  620.               writeln('INT ',section,' appears after INT ',lastSection);
  621.               if indexColumns>1 then begin
  622.             wl('This can be tolerated only with a single column index.');
  623.          error_Exit:
  624.             errorExit('Please correct the file and try again.',fileErr);
  625.               end; (* if indexColumns>1 *)
  626.               wl('It is recommended to correct the file.');
  627.               inc(warnings);
  628.             end; (* if INTno<lastINTno *)
  629.             if INTno<>lastINTno then begin
  630.               wrSection;
  631.               IntTopicStr:=Section+'_0';
  632.               if indexColumns=1 then begin
  633.             insertQueued;
  634.             queuedEntry:=s;
  635.               end; (* if indexColumns=1 *)
  636.               title:=INTtitles[INTno]^;
  637.               if title='' then title:='INT '+Section;
  638.               lastINTno:=INTno;
  639.             end; (* if INTno<>lastINTno *)
  640.           end; (* else (Classification <> '!') *)
  641.  
  642.           if backRef then AddTopic(SubIntFile,nl,'Interrupts','idInterrupts');
  643.             (* don't insert a backward reference the very first time *)
  644.           backRef:=true; (* but in all the rest *)
  645.           NewHlpPage(SubIntFile, title, IntTopicStr,'i:0', specialClassification);
  646.           if twoIndexes AND indexHeaders then
  647.             OutLn(IndexFile,'\par '+title);
  648.           LastSection := Section;
  649.         end; { if LastSection <> Section }
  650.  
  651.  
  652.           if TopicNo=1 then c:=specialClassification
  653.         (* The initial Interrupt List section should cary the
  654.            indexHeader.
  655.         *)
  656.           else c:=Classification;
  657.           NewHlpPage(IntTopics, s, TopicStr,'l:0', c);
  658.           if SpecialNote <> '' then
  659.         begin
  660.           writeln(IntTopics, '{\cf0 ', SpecialNote, '}'#13#10'\par ');
  661.           SpecialNote := '';
  662.         end; { if SpecialNote <> '' }
  663.  
  664.           OutLN(IntTopics, '{\cf0 Category: '+ Classification +
  665.         ' - ' + categoryStrings[Classification]^ + '}\par');
  666.           if Classification='!' then setTabs(IntTopics, 8, deciPoints, 10)
  667.         (* we will set tabs in the few Notes, but not in all the
  668.            INT entries.
  669.         *)
  670.           else if markKeys then OutLN(IntTopics,'{\b Inp.:}');
  671.           if twoIndexes then AddTopic(IndexFile, indentIndex, s, TopicStr);
  672.           AddTopic(SubIntFile, nl, s, TopicStr);
  673.         end { if NewSection }
  674.       else          { no new section }
  675.        begin
  676.          case current of
  677.            pastTest:     begin
  678.       { this paragraph is un-indented to gain space for code }
  679.       if markKeys then CheckKeyWords(s);
  680.  
  681.       { check the first two characters and react on '(T'[able nnnn)],
  682.     'Fo'[rmat of ...] and 'Bi'[tfields for ...]
  683.       }
  684.       if tables then case sR.w of
  685.     ta: if (length(s)>=12) AND (sR.d=able) AND (sR.c1=' ') AND (sR.c2=')')
  686.       AND (isNumber(sR.ti)>=0) then begin
  687.         hLineP:=@bufferString;
  688.         tLineP:=@s;
  689.       table:
  690.         if eof(F1) then begin
  691.           writeln('Unextected end of file in table at INT ',Section,
  692.         ' Subfunc ',SubFunc);
  693.           wrSection;
  694.           goto Stop;
  695.         end; (* if eof(F1) *)
  696.         readln(F1, bufferString);
  697.         inc(lineCount);
  698.         p:=pos('(Table ',tLineP^);
  699.         if (p=0) OR  (length(tLineP^)<p+11) OR (tLineP^[p+11]<>')')then begin
  700.       noTable:
  701.           inc(missingTableCounter);
  702.           if allMessages OR (missingTableCounter<=missingTableLimit) then begin
  703.         writeln('Missing "(Table nnnn)" in INT ',Section,
  704.           ' Subfunc ',SubFunc,' (line ',lineCount,'):');
  705.         writeln(pred(lineCount):5,s:succ(length(s)));
  706.         writeln(lineCount:5,bufferString:succ(length(bufferString)));
  707.         if missingTableCounter=missingTableLimit then begin
  708.           wl(#13#10'Several missing tables encountered. If '
  709.             +progName+' is used on release 40 or lower');
  710.           wl('of the List, it should be started with the program '
  711.             +'parameter -r40, or with key');
  712.           wl('releaseNo=40 in section [OPTIONS] of the configuration file.');
  713.           write('s=stop; m=messages; else continue without messages: ');
  714.           ProcessTime:=ProcessTime-memL[$40:$6C];
  715.           p:=readKeyWd;
  716.           ProcessTime:=ProcessTime+memL[$40:$6C];
  717.             (* sets ProcessTime "pause" ticks later than original *)
  718.           if word(p)<$100 then writeln (* function key *)
  719.           else begin
  720.             writeln(char(p));
  721.             case upcase(char(p)) of
  722.               'S': errorExit('Terminated by user',userErr);
  723.               'M': allMessages:=true;
  724.             end; (* if ... case ... of *)
  725.           end; (* if word(p)>$ff *)
  726.         end; (* if missingTableCounter=missingTableLimit *)
  727.         wrSection;
  728.           end; (* if allMessages ... *)
  729.           insert(nl,bufferString,1); (* force newline *)
  730.         end (* if (p=0) ... *)
  731.         else begin
  732.           tP:=@tLineP^[p+7];
  733.           curTab:=isNumber(tP^);
  734.           if curTab<0 then goto noTable;
  735.           toArray(curTab, tabArray, tabTop);
  736.           currentTable:=tP^;
  737.           table_Id:='t'+currentTable;
  738.           if inTable then insertRef;
  739.           inTable:=true;
  740.           tableTitle:=Section+' '+SubFunc+' '+hLineP^;
  741.           while tableAliasString=tableTitle do begin
  742.         saveAlias(nextAliasPP,tableAliasId+table_id);
  743.         getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  744.           end; (* while ... *)
  745.           NewHlpPage(TabTopics, tableTitle, table_Id,'t:0', tableClassification);
  746.           if tableWindow then begin
  747.         AddTopic(TabTopics,nl,'Copy to Main',table_Id+mainW);
  748.         OutLn(TabTopics,'');
  749.           end; (* if tableWindow *)
  750.           if sR.w=ta then begin (* bold Table nnnn *)
  751.         s[1]:='{';  (* substitutes '(' *)
  752.         s[12]:='}'; (*   and ')'       *)
  753.         insert('\b ',s,2);
  754.           end (* if sR.w=ta *)
  755.           else begin
  756.         writeln(TabTopics,'\par {\b Table ',currentTable,'}');
  757.         bufferString[0]:=char(pred(p)); (* delete '(Table nnnn)' *)
  758.           end; (* else *)
  759.           AddTopic(TableFile,nl+currentTable+'  ',tableTitle,table_Id);
  760.         end; (* else *)
  761.     end; (* case ta *)
  762.     fo: if pos('Format of ',s)=1 then begin
  763.       fobi:
  764.       hLineP:=@s;
  765.       tLineP:=@bufferString;
  766.       goto table;
  767.     end; (* case fo *)
  768.     bi: if pos('Bitfields for ',s)=1 then goto fobi;
  769.     else begin
  770.       p:=length(s)-4;
  771.       for q:=p downto 1 do begin
  772.         if (s[q]='#') AND ((q=p) OR (s[q+5]<'0') OR (s[q+5]>'9')) then begin
  773.           tP:=@s[q+1];
  774.           curTab:=isNumber(tP^);
  775.           if curTab>=0 then begin
  776.         toArray(curTab, refArray, refTop);
  777.         insert('}{\v t'+tP^+tableW+'}', S, q+5);
  778.         insert('{\uldb ', S, q);
  779.         if (length(s)-q>150) AND (q>20) then begin
  780.           (* we must ensure keeping length(S)<256 *)
  781.           bufferString:=copy(S, q, 255);
  782.           S[0]:=char(pred(q)); (* delete the copied part *)
  783.         end; (* if (length(s)-q>150)... *)
  784.           end; (* if isNumber *)
  785.         end; (* if (s[q]='#')... *)
  786.       end; (* for q=p *)
  787.     end; (* else *)
  788.       end; (* case sR.w of *)
  789.       { indent again }
  790.                  end; (* case pastTest *)
  791.            firstPart:    check1st(s);
  792.            inOverview:   getINTtitle(s,INTtitles);
  793.            inFlags:      scan(s,flagStrings);
  794.            inCategories: scan(s,categoryStrings);
  795.            inKeys:       scan(s,categoryKeyStrings);
  796.            inFileBreakSection: goto endOfLoop;
  797.          end; (* case current of *)
  798.          if inTable then OutLN(TabTopics, s) else OutLN(IntTopics, s);
  799.          if bufferString<>'' then begin
  800.            if inTable then OutLn(TabTopics, bufferString) (* with "newline" *)
  801.            else writeln(IntTopics, bufferString); (* no "newline" (\par ) *)
  802.            bufferString:='';
  803.          end; (* if bufferString<>'' *)
  804.        end; { else (no new section) }
  805.  
  806.       endOfLoop:
  807.     end; { while not(EOF(F1)) }
  808.  
  809.       STOP:
  810.       if inTable then insertRef;
  811.       inTable:=false;
  812.       insertRef;
  813.       close(F1);
  814.       ProcessIntList := TRUE;
  815.     end;
  816.  
  817.  
  818.   Procedure NewPage(VAR F: Text; Title : String);
  819.     VAR TopicStr : String;
  820.  
  821.       begin
  822.     Inc(TopicNo);
  823.     str(TopicNo, TopicStr);
  824.     AddTopic(IndexFile, nl, Title, TopicStr);
  825.     NewHlpPage(F, Title, TopicStr,'p:0', InvalidClassification);
  826.     setTabs(F, 8, deciPoints, 10);
  827.       end;
  828.  
  829.  
  830.   Procedure ProcessPorts(FName : String);
  831.     LABEL STOP;
  832.     VAR i          : integer;
  833.     s          : String;
  834.     TopicStr   : String;
  835.     NewSection : Boolean;
  836.     F1         : Text;
  837.  
  838.  
  839.  
  840.     begin
  841.       defaultDir(FName,InPath);
  842.      {$I-}
  843.       assign(F1, FName);
  844.       reset(F1);
  845.      {$I+}
  846.       if IOResult <> 0 then
  847.     begin
  848.       writeln('Unable to open ', FName);
  849.       EXIT;
  850.     end;
  851.  
  852.       writeln('Processing : ', FName);
  853.  
  854.       i:=length(FName);
  855.       while FName[i]<>'\' do dec(i);
  856.       NewPage(IntTopics, copy(FName,succ(i),255)+' Note');
  857.  
  858.       while not(EOF(F1)) do
  859.     begin
  860.       readLine(F1, s);
  861.       NewSection := (s[1]= '-') and (Pos('---------', s) <> 0);
  862.  
  863.       if NewSection then
  864.         begin
  865.           readLine(F1, s);
  866.  
  867.           if EOF(F1)  then   { last line of document ?}
  868.         goto STOP;
  869.  
  870.           if s <> '' then                { why does this happend }
  871.         NewPage(IntTopics, s);
  872.         end
  873.       else
  874.         begin
  875.          CheckKeyWords(s);
  876.          OutLN(IntTopics, s);
  877.         end;
  878.     end;
  879.  
  880.       STOP:
  881.       close(F1);
  882.     end;
  883.  
  884.  
  885.   Procedure ProcessFile(FName : String; Title : String);
  886.     VAR s          : String;
  887.     F1, F2     : Text;
  888.  
  889.     begin
  890.       defaultDir(FName,InPath);
  891.      {$I-}
  892.       assign(F1, FName);
  893.       reset(F1);
  894.      {$I+}
  895.       if IOResult <> 0 then
  896.     begin
  897.       writeln('Unable to open ', FName);
  898.       EXIT;
  899.     end;
  900.  
  901.       writeln('Processing : ', FName);
  902.       setTabs(IndexFile, 8, deciPoints, 10);
  903.  
  904.       while not(EOF(F1)) do
  905.     begin
  906.       readLine(F1, s);
  907.       OutLN(IndexFile, s);
  908.     end;
  909.  
  910.       close(F1);
  911.     end;
  912.  
  913.  
  914.   Procedure Credits;
  915.     begin
  916.       OutLn(IndexFile,'');
  917.       AddTopic(IndexFile, nl, 'Credits', 'idCredits');
  918.       OutLn(IndexFile,'');
  919.       OutLn(IndexFile,compilationStr);
  920.       NewHlpPage(IndexFile, 'Credits', 'idCredits','m:1', InvalidClassification);
  921.       OutLn(IndexFile,'\pard{\f0'+headerSize+
  922.     '\qc\par Interrupt List (c) by {\b Ralf Brown}\par'); { \qc=centered }
  923.       OutLn(IndexFile,'\par This list was converted from the released ASCII file'
  924.             + '\par to the Windows Help-Format by \par \par'
  925.             + '\par {\b Christian M\''81ller-Planitz}'+header2ndSize);
  926.       OutLn(IndexFile,e_mailCredits); { e-mail address }
  927.       writeIndex('\par\par Thanks to:');
  928.       writeIndex(ack01);
  929.       writeIndex(ack02);
  930.       writeIndex(ack03);
  931.       writeIndex(ack04);
  932.       writeIndex(ack05);
  933.       writeIndex('\par}');
  934.     end;
  935.  
  936.  
  937. procedure processTopics(n: integer);
  938. (* inserts references to n topics in the CONTENTS main index *)
  939.   var i: integer; w: string[13]; title,id: string[39];
  940.   begin
  941.     for i:=1 to n do begin
  942.       str(i,w);
  943.       insert('WINDOW ',w,1);
  944.       title:='';
  945.       profileString(w,'title',title,pred(sizeOf(title)));
  946.       id:='';
  947.       profileString(w,'id',id,pred(sizeOf(id)));
  948.       if (title<>'') AND (id<>'') then AddTopic(IndexFile,nl,title,id);
  949.     end; (* for i:=1 *)
  950.   end; (* procedure processTopics *)
  951.  
  952. procedure processPages(n: integer);
  953. (* processes n "windows" as defined in the configuration file *)
  954.   var
  955.     i,j,wType,files,fType: integer;
  956.     w: string[13];
  957.     f: string[17];
  958.     id: string[17];
  959.     fId,chain: string[21];
  960.     title,fTitle: string[39];
  961.     fileName: pathStr;
  962.   begin
  963.     for i:=1 to n do begin
  964.       str(i,w);
  965.       insert('WINDOW ',w,1);
  966.       title:='';
  967.       profileString(w,'title',title,pred(sizeOf(title)));
  968.       id:='';
  969.       profileString(w,'id',id,pred(sizeOf(id)));
  970.       if (title<>'') AND (id<>'') then begin
  971.     wType:=1;
  972.     profileInt(w,'type',wType);
  973.     files:=1;
  974.     profileInt(w,'files',files);
  975.     case wType of
  976.       1: NewHlpPage(IndexFile,title,id,'f:0',InvalidClassification);
  977.         (* Single entry windows *)
  978.       2: NewHlpPage(IndexFile,title,id,'m:9',InvalidClassification);
  979.         (* Multi entries windows *)
  980.       3: ; (* nop *)   (* Windows with own contents list *)
  981.     end; (* case wType of *)
  982.     for j:=1 to files do begin
  983.       str(j,f);
  984.       insert('file ',f,1);
  985.       fileName:='';
  986.       profileString(w,f,fileName,pred(sizeOf(fileName)));
  987.       if fileName<>'' then begin
  988.         fType:=wType;
  989.         profileInt(w,f+' type',fType);
  990.         case fType of
  991.           1: ProcessFile(fileName,title);
  992.           2: ProcessPorts(fileName);
  993.           3: begin
  994.         (* the RTF file is expecte to be in:
  995.              a. the current directory.
  996.              b. the program's home directory
  997.            if no drive or root is specified.
  998.         *)
  999.         if ((length(fileName)<2) OR (fileName[2]<>':'))
  1000.           AND (fileName[1]<>'\') AND (fileName[1]<>'.') then begin
  1001.           if exist(filename) OR NOT exist(homeDir+filename) then
  1002.             insert(currentDir,filename,1)
  1003.           else insert(homeDir,filename,1);
  1004.         end; (* if (fileName[2]<':'... *)
  1005.         fileName:=fExpand(fileName);
  1006.         if NOT exist(fileName) then
  1007.           writeln(#7'File ',fileName,' not found, copy to ',currentDir);
  1008.         writeln(HPJ,fileName); (* include the file name *)
  1009.           end;
  1010.           4: begin (* ASCII file in multi file entry *)
  1011.         str(j,fTitle);
  1012.         str(j,fId);
  1013.         insert(title+' - ',fTitle,1);
  1014.         insert(id+'_',fId,1);
  1015.         chain:=id+':5';
  1016.         profileString(w,f+' title',fTitle,pred(sizeOf(fTitle)));
  1017.         profileString(w,f+' id',fId,pred(sizeOf(fId)));
  1018.         profileString(w,f+' chain',chain,pred(sizeOf(chain)));
  1019.         NewHlpPage(IndexFile,fTitle,fId,chain,InvalidClassification);
  1020.         defaultDir(fileName,currentDir);
  1021.         ProcessFile(fileName,fTitle);
  1022.           end; (* case 4 *)
  1023.         end; (* case fType of *)
  1024.       end (* if fileName<>'' *)
  1025.       else writeln(#7'Missing file name for [',w,'] ',f);
  1026.     end; (* for j:=1 *)
  1027.       end (* if (title<>'') ... *)
  1028.       else writeln(#7'Missing title or identifier in ',w);
  1029.     end; (* for i:=1 *)
  1030.   end; (* procedure processPages *)
  1031.  
  1032. procedure processFilter;
  1033.   var d: dirStr;
  1034.   begin
  1035.     writeIndex('\page\pard');
  1036.     writeIndex('#{\footnote{#} idPartComp}');
  1037.     writeIndex('{\f0'+header2ndSize+' This compilation of the Interrupt List does '+#13#10
  1038.       +'not contain all the information in the List, see the '#13#10
  1039.       +'{\uldb INTERRUP.1ST File}{\v id1st} for the availability of the ');
  1040.     writeIndex('complete list.\par\par');
  1041.     writeIndex('See {\uldb Filter Method}{\v idFlt_meth} and '#13#10
  1042.       +'{\uldb Filter File}{\v idFlt_file} for details.\par}');
  1043.     d:=currentDir;
  1044.     if NOT exist('FLT_METH.RTF') then begin
  1045.       if exist(homeDir+'FLT_METH.RTF') then d:=homeDir
  1046.       else writeln(#7'File FLT_METH.RTF not found, copy to ',d);
  1047.     end; (* if NOT exist() *)
  1048.     writeln(HPJ,d,'FLT_METH.RTF');
  1049.     NewHlpPage(IndexFile, 'Filter File', 'idFlt_file','flt:1', invalidClassification);
  1050.     processFile(filterFileName,'Filter File');
  1051.   end; (* procedure processFilter *)
  1052.  
  1053. procedure readCategoryKeys;
  1054. (* Opens file CATEGORY.KEY if available, and reads definitions to
  1055.    categoryKeyStrings. Definitions are of the type
  1056.       A - definition A, B - definition B,
  1057.    The definitions are inserted as search keys for the appropriate
  1058.    categories. Note that more than one keyword per entry is accepted,
  1059.    separated by a semicolon, e.g. " c - cachers;spoolers,".
  1060.  
  1061.    Reads also title file OVERVIEW.LST.
  1062.  
  1063.    CATEGORY.KEY and OVERVIEW.LST are separate files in Interrupt List
  1064.    release 41+.
  1065. *)
  1066.   var t: text; s: string;
  1067.   begin
  1068. (*$I-*)
  1069.     assign(t,InPath+'category.key');
  1070.     reset(t);
  1071. (*$I+*)
  1072.     if IOresult<>0 then writeln('Unable to open ',InPath,'CATEGORY.KEY')
  1073.     else begin
  1074.       while NOT eof(t) do begin readln(t,s); scan(s,categoryKeyStrings); end;
  1075.       close(t);
  1076.     end; (* else *)
  1077. (*$I-*)
  1078.     assign(t,InPath+'overview.lst');
  1079.     reset(t);
  1080. (*$I+*)
  1081.     if IOresult<>0 then writeln('Unable to open ',InPath,'OVERVIEW.LST')
  1082.     else begin
  1083.       while NOT eof(t) do begin readln(t,s); getINTtitle(s,INTtitles); end;
  1084.       close(t);
  1085.     end; (* else *)
  1086.   end; (* procedure readCategoryKeys *)
  1087.  
  1088. procedure INTsToIndex;
  1089.   var i,j,k,l: word; s: string[3];
  1090.   begin
  1091.     for k:=0 to pred(indexPages) do begin
  1092.       l:=k*indexRows*indexColumns;
  1093.       for i:=0 to pred(indexRows) do begin
  1094.     OutLn(IntFile, '');
  1095.     for j:=0 to pred(indexColumns) do begin
  1096.       if INTcounts[l+i+j*16]<>0 then begin
  1097.         write(IntFile,'{\uldb INT ',HEX(l+i+j*16));
  1098.         if indexColumns=4 then write(IntFile,' List');
  1099.         write(IntFile,'}{\v ',HEX(l+i+j*16),'_0}');
  1100.       end (* if INTcounts[]<>0 *)
  1101.       else if indexColumns=4 then write(IntFile,'\tab ');
  1102.       if j<pred(indexColumns) then write(IntFile,'\tab ');
  1103.     end; (* for j:=0 *)
  1104.       end; (* for i:=0 *)
  1105.       if k<pred(indexPages) then OutLn(IntFile, '');
  1106.     end; (* for k:=0 *)
  1107.   end; (* procedure INTsToIndex *)
  1108.  
  1109.   const
  1110.     windows: integer = 0;
  1111.  
  1112.   var
  1113.     i: integer;
  1114.     ch: char;
  1115.  
  1116.   begin
  1117.     Intro;
  1118.     if (paramStr(1)='?') OR (paramStr(1)='-?') OR (paramStr(1)='/?')
  1119.       then Explain; (* and exit *)
  1120.  
  1121.     fSplit(paramStr(0),homeDir,currentDir,currentDir);
  1122.       (* works only with DOS 3.30+ - currentDir is used as a dummy *)
  1123.     currentDir:=fExpand('.');
  1124.     if length(currentDir)>3 then begin
  1125.       inc(currentDir[0]);
  1126.       currentDir[length(currentDir)]:='\';
  1127.     end; (* if length()... *)
  1128.     interpretParameters;
  1129.     initializeArrays;
  1130.     nextAliasPP:=@firstAliasP;
  1131.  
  1132.     if InPath='' then begin
  1133.       write('Source directory: ');
  1134.       readln(InPath);
  1135.     end; (* if InPath='' *)
  1136.     if InPath<>'' then begin
  1137.       ch:=InPath[length(InPath)];
  1138.       if (ch<>':') AND (ch<>'\') then
  1139.     begin inc(InPath[0]); InPath[length(InPath)]:='\'; end;
  1140.     end; (* if InPath<>'' *)
  1141.  
  1142.     if OutPath='' then begin
  1143.       write('Dest. directory (has to be created in advance) : ');
  1144.       readln(OutPath);
  1145.     end; (* if OutPath='' *)
  1146.     if OutPath<>'' then begin
  1147.       ch:=OutPath[length(OutPath)];
  1148.       if (ch<>':') AND (ch<>'\') then
  1149.     begin inc(OutPath[0]); OutPath[length(OutPath)]:='\'; end;
  1150.     end; (* if OutPath<>'' *)
  1151.  
  1152.     ProcessTime:=memL[$40:$6C]; { timer ticks since midnight }
  1153.     findDateAndCopyright;
  1154.     CreateHPJ;
  1155.  
  1156.     OpenRTF(IndexFile, 'INDEX.RTF');
  1157.     NewHlpPage(IndexFile, 'Contents:', 'CONTENTS','m:2', specialClassification);
  1158.  
  1159.     readCategoryKeys; (* reads also titles *)
  1160.     OpenRTF(IntFile,   'INT.RTF');
  1161.     OpenRTF(SubIntFile,'SUBINT.RTF');
  1162.     OpenRTF(IntTopics, 'INTTOPIC.RTF');
  1163.  
  1164.     if twoIndexes then
  1165.       AddTopic(IndexFile, nl, 'Interrupt Index',
  1166.     '!IfThenElse(IsMark("Compressed_Index"), '
  1167.     +'`JumpId("","idInterrupts")'', `JumpId("","idIndex")'')')
  1168.     else AddTopic(IndexFile, nl, 'Interrupts', 'idInterrupts');
  1169.     if tables then AddTopic(IndexFile, nl, 'Tables', 'idTables');
  1170.     AddTopic(IndexFile, nl, 'FILELIST', '1');
  1171.     AddTopic(IndexFile, nl, 'INTERRUP.1ST File', 'id1st');
  1172.     if filtered then begin
  1173.       AddTopic(IndexFile, nl, 'Filter Method', 'idFlt_meth');
  1174.       AddTopic(IndexFile, nl, 'Filter File', 'idFlt_file');
  1175.     end; (* if filtered *)
  1176.  
  1177.     profileInt('WINDOWS','number',windows);
  1178.     processTopics(windows); (* insert Ports, Memory etc. in index *)
  1179.  
  1180.     Credits;
  1181.  
  1182.     if twoIndexes then begin
  1183.       NewHlpPage(IndexFile, 'Interrupt Index', 'idIndex','m:3', specialClassification);
  1184.       AddTopic(IndexFile, nl, 'Compress index',
  1185.     '!SaveMark("Compressed_Index");JumpId("","idInterrupts")');
  1186.       { the program adds all following entries }
  1187.     end; (* if twoIndexes *)
  1188.     NewHlpPage(IntFile, 'Interrupts', 'idInterrupts','m:4', specialClassification);
  1189.     if twoIndexes then begin
  1190.       AddTopic(IntFile, nl, 'Expand index','!IfThen(IsMark("Compressed_Index"),'
  1191.     +' `DeleteMark("Compressed_Index")'');JumpId("","idIndex")');
  1192.       OutLn(IntFile, '');
  1193.       if indexColumns>1 then setTabs(IntFile, succ(ord(indexColumns<=4))*8,
  1194.     deciPoints, pred(indexColumns));
  1195.     end; (* if twoIndexes *)
  1196.  
  1197.     if tables then begin
  1198.       OpenRTF(TableFile, 'TABLE.RTF');
  1199.       OpenRTF(TabTopics, 'TABTOPIC.RTF');
  1200.       NewHlpPage(TableFile,'Tables\f1'+fontSize+'\par\par Tab# INT Func Title',
  1201.     'idTables','m:5', invalidClassification);
  1202.       (* "Tab# INT Func Title" in normal text font and size *)
  1203.     end; (* if tables *)
  1204.  
  1205.     profileList('ALIAS',aliasP); (* read [ALIAS] section from config. file *)
  1206.     getNextAlias(aliasP,aliasId,aliasString); (* get the first one (if any) *)
  1207.     profileList('TABLEALIAS',tableAliasP);
  1208.     getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  1209.  
  1210.     (* process either "interrup.lst" or "interrup.a".."interrup.?" *)
  1211.     if NOT ProcessIntList('interrup.lst') then begin
  1212.       ch := 'a';
  1213.       while ProcessIntList('interrup.'+ch) do inc(ch);
  1214.     end; (* if NOT ProcessIntList() *)
  1215.  
  1216.     if aliasString<>'' then begin
  1217.       writeln(#7'Alias string not found:'#13#10+'  "',aliasString,'"');
  1218.       if aliasP<>NIL then
  1219.     wl('One or more alias strings not processed.');
  1220.     end; (* if aliasP<>NIL *)
  1221.     if tableAliasString<>'' then begin
  1222.       writeln(#7'Table alias string not found:'#13#10+'  "',
  1223.     tableAliasString,'"');
  1224.       if tableAliasP<>NIL then
  1225.     wl('One or more table alias strings not processed.');
  1226.     end; (* if tableAliasP<>NIL *)
  1227.  
  1228.     if indexColumns=1 then insertQueued
  1229.     else INTsToIndex;
  1230.  
  1231.     NewHlpPage(IndexFile, 'INTERRUP.1ST File', 'id1st','f:0', invalidClassification);
  1232.       { the program adds all following entries }
  1233.     ProcessFile('interrup.1st', 'INTERRUP.1ST File');
  1234.     if filtered then processFilter;
  1235.  
  1236.     processPages(windows); (* process Ports, Memory etc. *)
  1237.  
  1238.     if firstAliasP<>NIL then begin
  1239.       writeln(HPJ,#13#10'[ALIAS]');
  1240.       processAliasList(firstAliasP);
  1241.     end; (* if (firstAliasP<>NIL)... *)
  1242.     closeRTF(IntFile);
  1243.     closeRTF(SubIntFile);
  1244.     closeRTF(IntTopics);
  1245.     if tables then begin
  1246.       closeRTF(TableFile);
  1247.       closeRTF(TabTopics);
  1248.     end; (* if tables *)
  1249.     closeRTF(IndexFile);
  1250.     close(HPJ);
  1251.     if missingTableCounter>=missingTableLimit then
  1252.       writeln(missingTableCounter,' missing tables encountered.');
  1253.     ProcessTime:=memL[$40:$6C]-ProcessTime;
  1254.     writeln('The processing took ',(ProcessTime*10+91) DIV 182,' seconds.');
  1255.       (* 18.2 clock ticks per second, rounded *)
  1256.     i:=(maxTabTop*100) DIV tableArraySize;
  1257.     if i>60 then writeln(i,'% table array usage.');
  1258.     i:=(maxRefTop*100) DIV tableArraySize;
  1259.     if i>60 then writeln(i,'% reference array usage.');
  1260.     if insertCounter<>0 then writeln('Inserted ',insertCounter,' table references.');
  1261.     if warnings<>0 then begin
  1262.       writeln('Issued ',warnings,' warning(s).');
  1263.       halt(1);
  1264.     end; (* if warnings<>0 *)
  1265.   end.
  1266.